#coding:utf8
'''
Created on 2017年8月6日

@author: SimonTeam
'''
class HtmlOutputer(object):
    
    def __init__(self):
        self.datas = []
        
    
    def output_html(self):
        file_out = open('output.html','w')
        
        file_out.write("<html>")
        file_out.write('<header><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></header>')
        file_out.write("<body>")
        file_out.write("<table>")
        
        for data in self.datas:
            file_out.write("<tr>")
            file_out.write("<td>%s</td>" %data['url'])
            file_out.write("<td>%s</td>" %data['title'].encode('utf-8'))
            file_out.write("<td>%s</td>" %data['summary'].encode('utf-8'))
            file_out.write("</tr>")
        
        
        file_out.write("</table>")
        file_out.write("</body>")
        file_out.write("</html>")
        
        file_out.close()
        

    
    def collect_data(self, data):
        if data is None:
            return
        
        self.datas.append(data) 
    
    
    
    



